{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin static %}
{% load ietf_filters %}
{% load person_filters %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
{% endblock %}
{% block title %}Documents for {{ ad.name }}{% endblock %}
{% block content %}
    {% origin %}
    <h1>Documents for {{ ad.name }}</h1>
    <a class="btn btn-primary my-3" href="{% url 'ietf.doc.views_search.ad_workload' %}">IESG dashboard</a>
    {% if blocked_docs %}
        <h2 class="mt-4">Blocking positions held by {{ ad.name }}</h2>
        <table class="table table-sm table-striped tablesorter">
            <thead>
                <tr>
                    <th scope="col" data-sort="document">Document</th>
                    <th scope="col" data-sort="status">Status</th>
                    <th scope="col" class="d-none d-sm-table-cell" data-sort="responsible">Responsible AD</th>
                    <th scope="col" data-sort="discusses">Discusses</th>
                </tr>
            </thead>
            <tbody>
                {% for doc in blocked_docs %}
                    <tr>
                        <td>{{ doc.displayname_with_link }}</td>
                        {% include "doc/search/status_columns.html" %}
                        <td class="d-none d-sm-table-cell">
                            {% if doc.ad %}
                                {% person_link doc.ad %}
                            {% else %}
                                <span class="text-body-secondary">(None)</span>
                            {% endif %}
                        </td>
                        <td>
                            {% for p in doc.blocking_positions %}
                                <span {% if p.is_old_pos %}class="text-body-secondary"{% endif %}>
                                    {% if p.is_old_pos %}
                                        {% person_link p.balloter class="text-reset" %}
                                    {% else %}
                                        {% person_link p.balloter %}
                                    {% endif %}
                                    ({% if p.discuss_time %}{{ p.discuss_time|timesince_days }}{% endif %}
                                    days ago{% if doc.get_state_url != "rfc" and p.rev != doc.rev %} for -{{ p.rev }}{% endif %})
                                    <br>
                                </span>
                            {% endfor %}
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
    {% if not_balloted_docs %}
        <h2 class="mt-4">Missing ballot positions for {{ ad.name }}</h2>
        <table class="table table-sm table-striped tablesorter">
            <thead>
                <tr>
                    <th scope="col" data-sort="document">Document</th>
                    <th scope="col" data-sort="status">Status</th>
                    <th scope="col" class="d-none d-sm-table-cell" data-sort="responsible">Responsible AD</th>
                </tr>
            </thead>
            <tbody>
                {% for doc in not_balloted_docs %}
                    <tr>
                        <td>{{ doc.displayname_with_link }}</td>
                        {% include "doc/search/status_columns.html" %}
                        <td class="d-none d-sm-table-cell">
                            {% if doc.ad %}
                                {% person_link doc.ad %}
                            {% else %}
                                <span class="text-body-secondary">(None)</span>
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
    <h2 class="mt-4">Documents for {{ ad.name }}</h2>
    {% include "doc/search/search_results.html" with start_table=True end_table=True %}
{% endblock %}
{% block js %}
    <script src="{% static "ietf/js/list.js" %}"></script>
{% endblock %}